package testemunhopublico;

import java.io.IOException;
import java.util.Date;

import org.jw.testemunhopublico.exceptions.NoFunctionalException;
import org.jw.testemunhopublico.service.impl.TurnoService;
import org.jw.testemunhopublico.util.Constantes;
import org.jw.testemunhopublico.util.PropertiesUtil;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	public static void main(String[] args) throws NoFunctionalException, IOException {
		testaDesignarPublicadores();
//		testaBeans();
//		testaPropertiesUtil();
	}

	private static void testaBeans() throws IOException {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				Constantes.APPLICATION_CONTEXT);
		BeanFactory factory = context;

		String[] beans = context.getBeanDefinitionNames();
		for (String string : beans)
			System.out.println(string);
	}
	
	private static void testaPropertiesUtil() throws IOException {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				Constantes.APPLICATION_CONTEXT);
		BeanFactory factory = context;

		PropertiesUtil labelUtil = (PropertiesUtil) context.getBean(PropertiesUtil.class);
		System.out.println(labelUtil.getValue("MSG001", "a"));
		System.out.println(labelUtil.getValue("home"));
		System.out.println(labelUtil.getValue("designar.automaticamente"));
	}

	private static void testaDesignarPublicadores()
			throws NoFunctionalException {
		ApplicationContext context = new ClassPathXmlApplicationContext(
				Constantes.APPLICATION_CONTEXT);
		BeanFactory factory = context;
		
		TurnoService tService = (TurnoService) context.getBean(TurnoService.class);

		Date di = new Date(114, 10, 1);
		Date df = new Date(114, 11, 1);

		tService.designarPublicadores(di, df);
	}

}
